home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / guile / 1.8 / lang / elisp / example.el < prev    next >
Encoding:
Text File  |  2008-12-17  |  1.2 KB  |  40 lines

  1.  
  2. (defun html-page (title &rest contents)
  3.   (concat "<HTML>\n"
  4.       "<HEAD>\n"
  5.       "<TITLE>" title "</TITLE>\n"
  6.       "</HEAD>\n"
  7.       "<BODY>\n"
  8.       (apply 'concat contents)
  9.       "</BODY>\n"
  10.       "</HTML>\n"))
  11.  
  12. (defmacro time (repeat-count &rest body)
  13.   `(let ((count ,repeat-count)
  14.      (beg (current-time))
  15.      end)
  16.      (while (> count 0)
  17.        (setq count (- count 1))
  18.        ,@body)
  19.      (setq end (current-time))
  20.      (+ (* 1000000.0 (+ (* 65536.0 (- (car end) (car beg)))
  21.             (- (cadr end) (cadr beg))))
  22.     (* 1.0 (- (caddr end) (caddr beg))))))
  23.  
  24. ;Non-scientific performance measurements (Guile measurements are with
  25. ;`guile -q --no-debug'):
  26. ;
  27. ;(time 100000 (+ 3 4))
  28. ; => 225,071 (Emacs) 4,000,000 (Guile)
  29. ;(time 100000 (lambda () 1))
  30. ; => 2,410,456 (Emacs) 4,000,000 (Guile)
  31. ;(time 100000 (apply 'concat (mapcar (lambda (s) (concat s "." s)) '("a" "b" "c" "d"))))
  32. ; => 10,185,792 (Emacs) 136,000,000 (Guile)
  33. ;(defun sc (s) (concat s "." s))
  34. ;(time 100000 (apply 'concat (mapcar 'sc  '("a" "b" "c" "d"))))
  35. ; => 7,870,055 (Emacs) 26,700,000 (Guile)
  36. ;
  37. ;Sadly, it looks like the translator's performance sucks quite badly
  38. ;when compared with Emacs.  But the translator is still very new, so
  39. ;there's probably plenty of room of improvement.
  40.